<template>
<h2>添加排房信息</h2>
<table border="1">
    <tr>
        <td>房型</td>
        <td>
            <select v-model="info.RtypeId">
                <option :value="0">--请选择--</option>
                <option v-for="item in Rtype" :value="item.RtypeId">{{ item.Rtype_Name }}</option>
            </select>
        </td>
    </tr>
    <tr>
        <td>房号</td>
        <td>
            <select v-model="info.Rnumber_Id">
                <option :value="0">--请选择--</option>
                <option v-for="item in Rnumber" :value="item.Rnumber_Id">{{ item.Rnumber_Name }}</option>
            </select>
        </td>
    </tr>
    <tr>
        <td>状态</td>
        <td>
           <input type="radio" :value="true" v-model="info.RRoom_Type">发布
           <input type="radio" :value="false" v-model="info.RRoom_Type">暂缓发布
        </td>
    </tr>
    <tr>
        <td></td>
        <td>
            <input type="button" value="保存" @click="SaveData">
        </td>
    </tr>
</table>

</template>
<script setup lang="ts">
import axios from "axios";
import { onMounted ,ref} from "vue";


const info=ref({
    Rnumber_Id:0,
    RtypeId:0,
    RRoom_Type:true

})

const Rtype=ref([{

    RtypeId:0,
    Rtype_Name:""

}])
const Rnumber=ref([{
    Rnumber_Id:0,
    Rnumber_Name:""
}])


onMounted(()=>{
    LoadRoomType();
    LoadRoomNumber();
})

const LoadRoomType=()=>{
    axios.get('https://localhost:7153/api/RowRoom/GetType')
    .then(res=>{
        Rtype.value=res.data
    })
}


const LoadRoomNumber=()=>{
axios.get('https://localhost:7153/api/RowRoom/GetRoomNumber')
.then(res=>{
    Rnumber.value=res.data
})

}

const SaveData=()=>{
    axios.post('https://localhost:7153/api/RowRoom/AddRowRoom',info.value)
    .then(res=>{
        if(res.data>0){
            alert("添加成功");

        }
        else{
            alert("添加失败");

        }
    })
}


</script>